package com.smartleanx.module.hrm.service.instation;

import lombok.Getter;
import lombok.RequiredArgsConstructor;

import java.util.HashMap;
import java.util.Map;

/**
 * 站内信
 *
 * @author xzq
 * @since 2025/7/14
 */
@Getter
@RequiredArgsConstructor
public enum InstationSmsTypeEnum {

    FILLIN("contract_fillin", "填写通知","%s给您发送合同《%s》，请完成填写"),

    SIGN("contract_sign", "签署通知","%s给您发送合同《%s》，请完成签署"),

    URGE_FILLIN("contract_urge_fillin", "催办通知","%s提醒您填写合同《%s》，请尽快完成填写"),

    URGE_SIGN("contract_urge_sign", "催办通知","%s提醒您签署合同《%s》，截止时间至%s，请尽快完成签署"),

    EXPIRED_SIGN("contract_expired_sign", "过期通知","%s提醒您应签署的合同《%s》，已超出签署截止时间自动作废，请获悉"),

    CONTRACT_FILLIN_SYSTEM("contract_fillin_system", "填写通知","%s已完成《%s》填写，请您继续完成填写"),

    CONTRACT_REFUSE_SYSTEM("contract_refuse_system", "拒签通知","%s拒签了您发送的合同《%s》，请尽快处理"),
    ;

    private final String code;
    private final String desc;
    private final String message;

    public static InstationSmsTypeEnum getTypeEnum(String type){
        for (InstationSmsTypeEnum value : InstationSmsTypeEnum.values()) {
            if(type.equals(value.getCode())){
                return value;
            }
        }
        return null;
    }

    public static String getMessageFormat(String name,String contractName,String time,String type){
        for (InstationSmsTypeEnum value : InstationSmsTypeEnum.values()) {
            if(type.equals(value.getCode())){
                String message = value.getMessage();
                return "4".equals(type)?String.format(message,name,contractName,time):String.format(message,name,contractName);
            }
        }
        return null;
    }


    public static Map<String, Object> getMapParam(String name,String contractName,String time,String type){
        Map<String, Object> mapParam = new HashMap<>();
        mapParam.put("userName",name);
        mapParam.put("contractName",contractName);
        if("contract_urge_sign".equals(type)){
            mapParam.put("time",time);
        }
        return mapParam;
    }
}
